#ifndef DATABASE_H
#define DATABASE_H

#include <QObject>
#include <QSqlDatabase>
#include <QSqlError>
#include <QSqlQueryModel>

#include "publicstruct.h"
#include "ganttmodel.h"
#include "qpagebar.h"



class database : public QObject
{
    Q_OBJECT
public:
    explicit database(QObject *parent = nullptr);
    QVector<DbInfo> vDbSource;
    DbInfo sqlLiteInfo;
    QString connStr;

signals:

public slots:
    bool initMysql(DbInfo di);          //初始化数据库连接
    bool initSqlite();          //初始化sqlite数据库连接
    bool initCfgData();         //读取sqlite中的配置信息
    int  getRecCount(QString strSql);         //获取记录总数

public:
    QMap<QString, QString> getDataDictFrSqlite();
    QStringList getComboBoxDataBySql(const QString &sqlStr);
    QList<PersonHours> getPersonHours(QString &userName, QDate &startDate, QDate &endDate);
    QList<GanttTask> getTaskDataByPrjName_new(QPageBar *pageBar/*,int curPage*/);
    QList<GanttTask> getTaskDataByDevName_new(QPageBar *pageBar/*,int curPage*/);
    QList<DeptDevTotalHours> getDeptDevTotalHours(QString &startDate, QString &endDate);
    QList<DeptDevTotalHoursByProject> getDeptDevTotalHoursByProject(QString &startDate, QString &endDate);
    QList<DevDetailHours> getDevDetailHours(QString &userName,QString &startDate, QString &endDate);
    bool getTaskesTimateFrTaskId(QString &tasksId, QDate &startDate, QDate &endDate);
    void getPagingInfo(QPageBar *pageBar/*,QString strSql*//*,int pageSize*/);

    QList<PrjVerPlan> getProjectVerPlan(const QString &productName);
    QList<StoryTaskByVer> getStoryTaskByVerPlan(const QString &verPlanId);
    QList<UserHolidayInfo> getUserAttendanceFrDb(QString &userName,QString &startDate, QString &endDate);
    QMap<QString, QString> getProjectCostInfo();
};


#endif // DATABASE_H
